<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    header {
      width: 375px;
      height: 60px;
      background-color: lightcoral;
      text-align: center;
      line-height: 60px;
    }
  </style>
</head>
<body>
  <div id="app">
    <!-- 插槽可以将父组件的内容，插入给子组件使用(父传子) -->
    <!-- 插槽不仅可以传数据/变量，还可以传入标签/其他组件 -->
    <h1>这是父组件</h1>
    <!-- <child>{{count}}</child> -->
    <child>
      <i>哈哈哈</i>
    </child>

    <hr>

    <header-component title="猫眼电影">
      <button>菜单</button>
    </header-component>
    <br>
    <header-component title="朗朗人生">
      <span>🏀</span>
    </header-component>
  </div>

  <script src="../Vue.js"></script>

  <script>
    const { createApp } = Vue;

    const Child = {
      // template相当于是child标签的outterHtml属性
      // <slot></slot>相当于是插槽
      template: `
        <div>
          <h2>这是子组件</h2>
          <slot></slot>
        </div>
      `,
    };

    const HeaderComponent = {
      props: ["title"],
      template: `
        <header>
          {{title}}
          <slot></slot>
        </header>
      `
    }

    createApp({
      data() {
        return {
          count: 123
        }
      },
      methods: {},
      components: {
        Child,
        HeaderComponent
      }
    }).mount("#app")
  </script>
</body>
</html>